#ifndef PLAYER_H
#define PLAYER_H

#include "change.h"
#include <SFML/System.hpp>
#include <SFML/Network.hpp>
#include <list>



/**
 * The player represents a connected client. It has an ip, port and the player's id
 * as well as a reference to the player's ship in the game.
 */
class Player
{
	public:
		enum PLAYER_STATE { CONNECTING, SYNCHRONIZING, SYNCHRONIZED, PLAYING }; // TODO: This is defined in 3 places!!! unify!

		sf::Uint32 id; ///< The player unique ID
		std::string alias; ///< the playre choosen name.
		sf::IPAddress address; ///< the IP adress
		unsigned short port; ///< and the port he seems to use.
		sf::Uint32 shipID; ///< The ship he currently pilots
		//sf::Uint32 controls; // now a member on the ship.
		// lastCommandReceived // For discarding old packets

		// Perhaps a more general state is required,
		// for now we use it to know that we have to send the entire world to a client.
		PLAYER_STATE state;

		// List of changes player needs to execute to come up-to-date (after just connecting)
		std::list<Change*> changes;
		sf::Uint32 confirmedChangeNumber; // Client has confirmed to have received changes up to this changeNumber
		sf::Uint32 changeNumberWhenConnected;
		sf::Uint32 connectionTime;

		Player(sf::Uint32 _id, std::string _alias, sf::IPAddress _address, unsigned short _port);
		virtual ~Player();
	protected:
	private:
};

#endif // PLAYER_H
